function showPopover(directObject, messageText, position, html)
{
	position = position || 'right';
	html = html || false;
	directObject.popover('destroy');
	directObject.popover({'trigger':'manual','html':html,'content':messageText,'title':'Внимание!','placement':position});
	directObject.popover('show');
	setTimeout(function(){directObject.popover('hide');},3000);
}


$(document).ready(
	function ()
	{
		if (typeof mySettings !== "undefined") $('.markItUp').markItUp(mySettings);
		
		$('#authForm').submit(
			function ()
			{
				var login = $.trim($('#authFormLogin').val()).toLowerCase();
				var password = $.trim($('#authFormPass').val());
				var pPass = f_mymd5(login + "" + password);
				var pAuthHash = f_mymd5(login + "" + pPass + "" + hashId);
				$('#authFormPass').val('');
				$('#pPass').val(pAuthHash);
				return true;
			}
		);
		
		$('#passwordRecoveryForm').submit(
			function ()
			{
				email = $("#recFormEmail").val();
				if (!validEmail(email)) 
				{
					alert("E-mail имеет неверный формат");
					return false;
				}				
				return true;
			}
		);
		
		$('#passwordRecoveryDiv').show();
		
		$('#submitCancel').click(
			function ()
			{
				$("#recFormPassword").val("");
				$("#iRecFormPassword").val("");
			}
		)
		
		$('#acceptRecPassForm').submit(
			function ()
			{
				
				var pEmail = $.trim($('#pEmailAcceptRec').val()).toLowerCase();
				var password = $.trim($('#recFormPassword').val());
				var iPassword = $.trim($('#iRecFormPassword').val());
			
				if (password.length < 5)
				{
					alert("Пароль должнен быть не короче пяти символов");
					return false;
				}
				
				
				if (password != iPassword)
				{
					alert("Пароли не совпадают");
					return false;
				}
				
				if (password != '')
				{
					var pPass = f_mymd5(pEmail + "" + password);
					$('#recFormPassword').val(pPass);
				}				
				
				return true;
				
			}
		);


	function validEmail(email)
	{
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		return filter.test(email);
	}
	
	}
)